cmake_minimum_required(VERSION 3.10)
project(model_predictive_control)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)

if (COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else ()
    message(FATAL_ERROR "The compiler ${CMAKE_CXX_FLAGS} doesn't have C++11 support.
                         Please use a different C++ compiler")
endif ()

set(ADDITIONAL_CXX_FLAG "-Wall -O3 -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAG}")

#让能够命中断点
set(CMAKE_BUILD_TYPE Debug)
# 查找 Eigen3 和 OsqpEigen
find_package(Eigen3 REQUIRED)
find_package(OsqpEigen REQUIRED)
# find_package(PythonLibs 2.7 COMPONENTS Development NumPy)
find_package(PythonLibs 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})

add_executable(model_predictive_control main.cpp)
# 链接 Eigen3 和 OsqpEigen
target_link_libraries(model_predictive_control
    Eigen3::Eigen
    OsqpEigen::OsqpEigen
)
target_include_directories(model_predictive_control PRIVATE ${PYTHON_INCLUDE_DIRS})
target_link_libraries(model_predictive_control ${PYTHON_LIBRARIES})
